from django.db import models
from django.utils import timezone

# Create your models here.


class JSTOpen(models.Model):
    urls = models.TextField(verbose_name='聚水潭开发接口地址')
    app_key = models.TextField(verbose_name='聚水潭开发平台 APP Key')
    app_secret = models.TextField(verbose_name='聚水潭开发平台 APP Secret', null=True, blank=True)
    data_start_time = models.DateTimeField(verbose_name='获取数据的开始时间', default=timezone.now)

    def __str__(self):
        return self.urls

    class Meta:
        verbose_name = '聚水潭开放平台信息'
        verbose_name_plural = verbose_name


class JSTOpenImage(models.Model):
    name = models.CharField(max_length=256, verbose_name='商品名称', null=True, blank=True)
    number = models.CharField(max_length=256, verbose_name='商品编码', null=True, blank=True)
    paths = models.TextField(verbose_name='图片地址', null=True, blank=True)
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='图片创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name='图片更新时间')

    def __str__(self):
        return self.number

    class Meta:
        verbose_name = '聚水潭商品编码'
        verbose_name_plural = verbose_name


class IpoImage(models.Model):
    username = models.CharField(max_length=256, verbose_name='用户名', null=True, blank=True)
    image_name = models.TextField(verbose_name='用户对比图片', null=True, blank=True)
    paths = models.TextField(verbose_name='字段废除', null=True, blank=True)

    name_net50  = models.CharField(max_length=256, verbose_name='商品名称(ResNet50模型)', null=True, blank=True)
    number_net50  = models.CharField(max_length=256, verbose_name='商品编码(ResNet50模型)', null=True, blank=True)
    jst_paths_net50 = models.TextField(verbose_name='本地图片地址(ResNet50模型)', null=True, blank=True)
    net50_sim = models.CharField(max_length=256, verbose_name='相似度(ResNet50模型)', null=True, blank=True)
    time_net50_consuming = models.CharField(max_length=256, verbose_name='耗时(秒)(ResNet50模型)', null=True, blank=True)

    name_net101  = models.CharField(max_length=256, verbose_name='商品名称(ResNet101模型)', null=True, blank=True)
    number_net101  = models.CharField(max_length=256, verbose_name='商品编码(ResNet101模型)', null=True, blank=True)
    jst_paths_net101 = models.TextField(verbose_name='本地图片地址(ResNet101模型)', null=True, blank=True)
    net101_sim = models.CharField(max_length=256, verbose_name='相似度(ResNet101模型)', null=True, blank=True)
    time_net101_consuming = models.CharField(max_length=256, verbose_name='耗时(秒)(ResNet101模型)', null=True, blank=True)

    accuracy = models.CharField(max_length=256, verbose_name='是否准确', null=True, blank=True)
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='记录创建时间')

    def __str__(self):
        return self.username

    class Meta:
        verbose_name = '以图识图记录'
        verbose_name_plural = verbose_name


class Feature(models.Model):
    model = models.CharField(max_length=256, verbose_name='模型名称')
    features = models.JSONField(default=list, verbose_name='模型特征')
    update_time = models.DateTimeField(auto_now=True, verbose_name='更新时间')

    class Meta:
        verbose_name = '特征向量'
        verbose_name_plural = verbose_name
